#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int n,l,r,max=0;
	cin>>n>>l>>r;
	if(l-r>=n) {
		max=n-1;
	} else {
		for(int i=l; i<=r; i++) {
			if(i%n>max) {
				max=i%n;
			}
		}
	}
	cout<<max;
	fclose(stdin);
	fclose(stdout);
	return 0;
}
